﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETDBTableAdapters;
using System.Data.SqlClient;

public partial class Administration_navigation_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String stringId = Request.QueryString["id"];
        if (stringId != null)
        {
            int id = int.Parse(stringId);
            NavigationTableAdapter adapter = new NavigationTableAdapter();
            try
            {
                adapter.DeleteNavigationItem(id);
            }
            catch (SqlException ex)
            {
                Session.Add("ErrorMessage", "Please remove the content first");
                Response.Redirect("/CMSProject/Administration/error.aspx");
            }
            Response.Redirect("index.aspx", true);
        }
        else
        {
            Session.Add("ErrorMessage", "Item not found");
            Response.Redirect("/CMSProject/Administration/error.aspx");
        }
        
    }
}